{% extends 'mathesar/base.html' %}
{% load static %}

{% block title %}Home{% endblock %}

{% block styles %}
  {% if not development_mode %} 
    {% for css_file in manifest_data.module_css %}
      <link rel="stylesheet" href="{% static css_file %}" />
    {% endfor %} 
  {% endif %}
{% endblock %}

{% block scripts %}
  {{ common_data|json_script:"common-data" }}
  {% if route_specific_data %}
    {% for key, value in route_specific_data.items %}
        {{ value|json_script:key }}
    {% endfor %}
  {% endif %}

  {% if development_mode %}
    <script type="module" src="{{ dev_display_language_url }}"></script>
    {% if include_i18n_fallback %}
      <script type="module" src="{{ dev_fallback_language_url }}"></script>
    {% endif %}

    <script type="module" src="{{ client_dev_url }}/@vite/client"></script>
    <script type="module" src="{{ client_dev_url }}/src/main.ts"></script>
  {% else %}
    <script type="module" src="{{ prod_display_language_urls.module }}"></script>
    {% if include_i18n_fallback %}
      <script type="module" src="{{ prod_fallback_language_urls.module }}"></script>
    {% endif %}

    <!-- For legacy browsers that do not support modules -->
    <script nomodule>
      !(function () {
        var e = document,
          t = e.createElement("script");
        if (!("noModule" in t) && "onbeforeload" in t) {
          var n = !1;
          e.addEventListener(
            "beforeload",
            function (e) {
              if (e.target === t) n = !0;
              else if (!e.target.hasAttribute("nomodule") || !n) return;
              e.preventDefault();
            },
            !0
          ),
            (t.type = "module"),
            (t.src = "."),
            e.head.appendChild(t),
            t.remove();
        }
      })();
    </script>

    <script type="module" src="{% static manifest_data.module_js %}"></script>
    <script
      nomodule
      src="{% static manifest_data.legacy_polyfill_js %}"
    ></script>

    <script
      nomodule
      id="vite-legacy-display-lang-slot"
      data-src="{{ prod_display_language_urls.legacy }}"
    >
      System.import(
        document.getElementById("vite-legacy-display-lang-slot").getAttribute("data-src")
      );
    </script>

    {% if include_i18n_fallback %}
      <script
        nomodule
        id="vite-legacy-fallback-lang-slot"
        data-src="{{ prod_fallback_language_urls.legacy }}"
      >
        System.import(
          document.getElementById("vite-legacy-fallback-lang-slot").getAttribute("data-src")
        );
      </script>
    {% endif %}

    <script
      nomodule
      id="vite-legacy-js-slot"
      data-src="{% static manifest_data.legacy_js %}"
    >
      System.import(
        document.getElementById("vite-legacy-js-slot").getAttribute("data-src")
      );
    </script>
    
  {% endif %}
{% endblock %}
